<?php
namespace app\cron\controller;
use app\common\controller\BaseApi;

class Cabinet extends BaseApi
{
    public function _initialize()
    {
        $sk = input("sk/s");
        if ($sk != "27615e64890e433c74e9eb34f974d07e") {
        	header('Content-Type:text/html; charset=utf-8');
        	echo "404";die;
        }
    }
    public function updateCabinetStatus()
    {
        $today = date("Y-m-d");
        $cabinet_ids = db("gym_cabinet_order")->where(array("status" => 1, "end_date" => array("lt", $today)))->column("cabinet_id");
        if (!empty($cabinet_ids)) {
            //合同过期
            db("gym_cabinet_order")->where(array("status" => 1, "end_date" => array("lt", $today)))->update(array("status" => 0));

            //柜子设为未解绑
            db("gym_cabinet")->where(array("id" => array("in", $cabinet_ids)))->update(array("status" => 3));
        }
		header('Content-Type:text/html; charset=utf-8');
        echo "updateCabinetStatus--success";die;
    }
}